package cn.edu.xmu.server.service;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

@Service
public class SendService {
    private final static Logger logger = LoggerFactory.getLogger(SendService.class);
    RocketMQTemplate rocketMQTemplate;
    @Autowired
    public SendService(RocketMQTemplate rocketMQTemplate)
    {
        this.rocketMQTemplate=rocketMQTemplate;
    }

    public void sendMsg(String chatMsg) {
        Message<String> msg = MessageBuilder.withPayload(chatMsg)
                .build();
        this.rocketMQTemplate.send("SINGLE_CHAT",msg);
    }

}
